﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StoragePeriod.IDAL.StorageForecast;
using StoragePeriod.DALFactory;
using StoragePeriod.Model.StorageForecast;
using System.Data;

namespace StoragePeriod.BLL.StorageForecast
{
    /// <summary>
    /// 指标值区间说明
    /// </summary>
    public partial class T_QuotaPrompt
    {
        I_QuotaPrompt dal = new DataAccess<I_QuotaPrompt>().CreateInstance("StorageForecast.D_QuotaPrompt");
        public T_QuotaPrompt()
        { }
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int PromptID)
        {
            return dal.Exists(PromptID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(E_QuotaPrompt model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(E_QuotaPrompt model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int PromptID)
        {

            return dal.Delete(PromptID);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string PromptIDlist)
        {
            return dal.DeleteList(PromptIDlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public E_QuotaPrompt GetModel(int PromptID)
        {

            return dal.GetModel(PromptID);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<E_QuotaPrompt> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<E_QuotaPrompt> DataTableToList(DataTable dt)
        {
            List<E_QuotaPrompt> modelList = new List<E_QuotaPrompt>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                E_QuotaPrompt model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new E_QuotaPrompt();
                    if (dt.Rows[n]["PromptID"].ToString() != "")
                    {
                        model.PromptID = int.Parse(dt.Rows[n]["PromptID"].ToString());
                    }
                    if (dt.Rows[n]["QuotaID"].ToString() != "")
                    {
                        model.QuotaID = int.Parse(dt.Rows[n]["QuotaID"].ToString());
                    }
                    if (dt.Rows[n]["RawTypeID"].ToString() != "")
                    {
                        model.RawTypeID = int.Parse(dt.Rows[n]["RawTypeID"].ToString());
                    }
                    if (dt.Rows[n]["StartNum"].ToString() != "")
                    {
                        model.StartNum = decimal.Parse(dt.Rows[n]["StartNum"].ToString());
                    }
                    if (dt.Rows[n]["EndNum"].ToString() != "")
                    {
                        model.EndNum = decimal.Parse(dt.Rows[n]["EndNum"].ToString());
                    }
                    model.Prompt = dt.Rows[n]["Prompt"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  Method
    }
}
